#include<bits/stdc++.h>
using namespace std;
int n,m,V,L,t,f[100006],lim[100006],d[100005],v[100005],a[100005],pos[100005],ops,dis,ll,rr,tab[1000006],ans;
long double op,ppos[100005];
inline void solve(int l,int r){
	lim[r+1]=max(lim[r+1],l);
	ans++;
//	cout<<l<<" = "<<r<<"\n";
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&t);
	while(t--){
		ans=0;
		scanf("%d %d %d %d",&n,&m,&L,&V);
		memset(f,0,sizeof(f));
		memset(lim,0,sizeof(lim));
		for(int i=1;i<=n;i++){
			scanf("%d %d %d",d+i,v+i,a+i);
		}
		for(int i=1;i<=m;i++){
			scanf("%d",pos+i);
		}
		pos[m+1]=1000000000;
		for(int i=1;i<=m+1;i++) ppos[i]=pos[i];
		for(int i=1;i<=n;i++){
//			cout<<i<<"!\n";
			if(a[i]==0){
				if(v[i]>V){
					ops=lower_bound(pos+1,pos+m+2,d[i])-pos;
					if(ops<=m) solve(ops,m);
				}
			}else if(a[i]<0){
				if(v[i]>V){
					ops=lower_bound(pos+1,pos+m+2,d[i])-pos;
					if(ops<=m){
						if(V*V<v[i]*v[i]+2ll*a[i]*(pos[ops]-d[i])){
							int l=ops,r=m,mid;
							while(l<r){
								mid=(l+r+1)>>1;
								if(V*V<v[i]*v[i]+2ll*a[i]*(pos[mid]-d[i])){
									l=mid;
								}else{
									r=mid-1;
								}
							}
//							cout<<ops<<" "<<l<<" "<<fixed<<setprecision(10)<<v[i]*v[i]+2*a[i]*(pos[l]-d[i])<<" "<<V*V<<"**\n";
							solve(ops,l);
						}
					}
					
				}
			}else{
				dis=d[i];
				if(v[i]<=V){
					op=(V*V-v[i]*v[i])/2.0/a[i];
					op=d[i]+op;
					ops=upper_bound(ppos+1,ppos+m+2,op)-ppos;
				}else{
					op=dis;
					ops=lower_bound(pos+1,pos+m+2,dis)-pos;
				}
//				cout<<dis<<" "<<fixed<<setprecision(2)<<op<<"))\n";
				
//				if(pos[ops]*2*a[i]<2*a[i]*d[i]+(V*V-v[i]*v[i])) cout<<i<<"-"<<fixed<<setprecision(10)<<op<<" "<<pos[ops]<<' '<<ops<<' '<<m<<"@\n";
//				if(op-ppos[ops]>0.000001) cout<<"{\n";
//				cout<<ppos[ops]<<" "<<fixed<<setprecision(10)<<op<<"\n";
				if(ops<=m) solve(ops,m);
			}
		}
		f[0]=0;
		tab[ll=rr=1]=0;
		for(int i=1;i<=m+1;i++){
			lim[i]=max(lim[i],lim[i-1]);
			while(tab[ll]<lim[i] && ll<=rr) ll++;
			f[i]=f[tab[ll]]+1;
			while(f[tab[rr]]>=f[i]&& rr>=ll) rr--;
			tab[++rr]=i;
		}
		cout<<ans<<' '<<m-f[m+1]+1<<'\n';
	}
	return 0;
}
